<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\SiteArticle;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;

class SiteArticleController extends AdminController
{

    protected $cate_ids = [0 => '协议说明', 1 => '帮助信息',2 =>'系统通知'];

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new SiteArticle(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('cate_id')->using($this->cate_ids)->filter();
            $grid->column('title');
            $grid->column('summary');
            $grid->column('image')->image('', 60);
            $grid->column('created_at');
            $grid->model()->orderByDesc('id');
            $grid->disableViewButton();

        });
    }


    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new SiteArticle(), function (Form $form) {
            $form->display('id');
            $form->radio('cate_id')->options($this->cate_ids)->default(0);
            $form->text('title');
            $form->textarea('summary');
            $form->image('image');
            $form->editor('content');

            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
